package main

import (
	"flag"
	"fmt"

	_ "gitee.com/cjianwen/go/demo/socks_v2/raft_demo/server/entries"
	"gitee.com/cjianwen/go/demo/socks_v2/raft_demo/server/global"
	_ "gitee.com/cjianwen/go/demo/socks_v2/raft_demo/server/net"
	_ "gitee.com/cjianwen/go/demo/socks_v2/raft_demo/server/roles"
	"gitee.com/cjianwen/go/logs"
	"gitee.com/cjianwen/go/service"
)

func main() {
	flag.UintVar(&global.ServerInfo.ServerId, "sid", 1, "server id")
	flag.UintVar(&global.ServerInfo.ServerCount, "sc", 3, "server count")
	flag.Parse()

	logFile := fmt.Sprintf("./logs/%d.log", global.ServerInfo.ServerId)

	logs.InitDefaultLog(logFile)
	global.ServerInfo.Init()

	logs.Printf("server count = %d", global.ServerInfo.ServerCount)
	logs.Printf("server start: sid = %d, listen port = %d, log file = %s", global.ServerInfo.ServerId, global.ServerInfo.GetListenPort(), logFile)

	service.Start()
}
